package com.ecy.quadratic.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ecy.quadratic.R;

public class LFooter extends RelativeLayout {

    private FooterListener mListener;
    private TextView mPreSectionTV;
    private TextView mNextSectionTV;

    public LFooter(Context context) {
        super(context);
        init(context);
    }

    public LFooter(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public LFooter(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public void init(Context context) {

        View rootView = inflate(context, R.layout.comic_reader_footer, this);
        mPreSectionTV = (TextView) rootView.findViewById(R.id.tvPreSection);
        mNextSectionTV = (TextView) rootView.findViewById(R.id.tvNextSection);
        mPreSectionTV.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
//                ToastUtils.getSingleToast("preClick:",Toast.LENGTH_SHORT).show();
                if (mListener != null) {
                    mListener.onPreSection();
                }
            }
        });
        mNextSectionTV.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
//                ToastUtils.getSingleToast("NextClick:",Toast.LENGTH_SHORT).show();
                if (mListener != null) {
                    mListener.onNextSection();
                }
            }
        });
    }

    public void setFooterListener(FooterListener listener) {
        mListener = listener;
    }

    public interface FooterListener {
        void onPreSection();

        void onNextSection();
    }
}